import 'package:nylo_framework/nylo_framework.dart';
import 'dart:convert';

CommonResult commonResultFromJson(String str) =>
    CommonResult.fromJson(json.decode(str));

String commonResultToJson(CommonResult data) => json.encode(data.toJson());

class CommonResult<T> extends Model {
  CommonResult({
    num? code,
    T? data,
    String? msg,
  }) {
    _code = code;
    _data = data;
    _msg = msg;
  }

  CommonResult.fromJson(dynamic json) {
    _code = json['code'];
    _data = json['data'];
    _msg = json['msg'];
  }

  num? _code;
  T? _data;
  String? _msg;

  CommonResult copyWith({
    num? code,
    T? data,
    String? msg,
  }) =>
      CommonResult(
        code: code ?? _code,
        data: data ?? _data,
        msg: msg ?? _msg,
      );

  num? get code => _code;

  dynamic get data => _data;

  String? get msg => _msg;

  Map<String, dynamic> toJson() {
    final map = <String, dynamic>{};
    map['code'] = _code;
    map['data'] = _data;
    map['msg'] = _msg;
    return map;
  }
}
